<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    window.number = 2;
    var obj = {
        number: 3,
        db1: (function(){
            console.log('立即this',this);
            this.number *= 4; //? 8
            return function(){
                console.log('匿名this',this);
                this.number *= 5; //? 40
            }
        })()
    }
    /*
    ? 1.执行db1()时，this指向全局作用域，所以立即执行函数里，window.number * 4 = 8，然后执行匿名函数， 所以window.number * 5 = 40；
    ? 2.执行obj.db1()时，this指向obj对象，执行匿名函数，所以obj.number * 5 = 15
     */
    var db1 = obj.db1;
    db1();
    obj.db1();
    console.log('obj.number',obj.number);     //? 15
    console.log('windowNumber',window.number);  //? 40

</script>
</body>
</html>
